package www.nfin.ya.entity.excel;

import lombok.Data;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

@Data
public class WorkbookEntity {
    private String bookName;
    private List<SheetEntity> sheetEntities = new ArrayList<>();

    public XSSFWorkbook createWorkBook(){
        XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
        if(sheetEntities != null){
            for (SheetEntity sheetEntity : sheetEntities) {
                sheetEntity.writeXSSFSheet(xssfWorkbook);
            }
        }
        return xssfWorkbook;
    }
    public SheetEntity createSheet(){
        SheetEntity sheetEntity = new SheetEntity();
        sheetEntities.add(sheetEntity);

        return sheetEntity;
    }
    public boolean addSheetEntity(SheetEntity sheetEntity){
        sheetEntities.add(sheetEntity);
        return true;
    }
}
